//
//  OverlayView.m
//  SlashEM
//
//  Created by dirk on 1/7/10.
//  Copyright 2010 Dirk Zimmermann. All rights reserved.
//

//  This file is part of Slash'EM.
//
//  Slash'EM is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, version 2 of the License only.
//
//  Slash'EM is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with Slash'EM.  If not, see <http://www.gnu.org/licenses/>.

#import "OverlayView.h"
#import "ActionBar.h"
#import "MainViewController.h"
#import "ZStack.h"

@implementation OverlayView

@synthesize actionBar, contentView;

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
		self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

		contentView = [[UIView alloc] initWithFrame:self.bounds];
		contentView.autoresizingMask = self.autoresizingMask;
		[self addSubview:contentView];
		[contentView release];

		actionBar = [[ActionBar alloc] initWithFrame:self.bounds];
		CGRect actionBarFrame = actionBar.frame;
		actionBarFrame.origin.y = self.bounds.size.height-actionBarFrame.size.height;
		actionBar.frame = actionBarFrame;
		[self addSubview:actionBar];
		[actionBar release];
		
		CGRect contentViewFrame = contentView.frame;
		contentViewFrame.size.height -= actionBarFrame.size.height;
		contentView.frame = contentViewFrame;
    }
    return self;
}

- (void)removeFromSuperview {
	[super removeFromSuperview];
	[[MainViewController instance] popOverlayView:self];
}

- (void)dealloc {
    [super dealloc];
}

@end
